﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <unordered_map>
using namespace std;

class Solution {
public:
    int minimumTotal(vector<vector<int>>& triangle) {
        vector<int> ret(1, 0);
        ret[0] = triangle[0][0];
        int n = triangle.size();
        if (n == 1) return ret[0];
        int mini = 100000;
        for (int i = 2; i <= n; i++)
        {
            ret.resize(i);
            for (int j = i - 1; j >= 0; j--)
            {
                if (j == i - 1) ret[j] = ret[j - 1] + triangle[i - 1][j];
                else if (j == 0) ret[j] = ret[j] + triangle[i - 1][j];
                else ret[j] = min(ret[j - 1] + triangle[i - 1][j], ret[j] + triangle[i - 1][j]);
                if (i == n) mini = min(mini, ret[j]);
            }
        }
        return mini;
    }
};

int main()
{
    vector<int> arr(10, 0);
    return 0;
}
